#include <REGX52.H>
#include "Delay.h"
#include "Key.h"
#include "Nixie.h"
#include "Timer0.h"

sbit Motor=P1^0;

unsigned char KeyNum,Speed;
unsigned char T0Count,Compare=0;

void main()
{
	Timer0_Init();
	Nixie(1,Speed);
	while(1)
	{
		KeyNum=Key();
		if(KeyNum==1)
		{
			Speed++;
			Speed%=10;
			if(Speed){Compare=Speed*5+55;}
			else{Compare=Speed;}	
		}
		Nixie(1,Speed);
	}
}

void Timer0_Routine() interrupt 1
{
	TL0 = 0x9C;				
	TH0 = 0xFF;
	T0Count++;
	T0Count%=100;
	if(T0Count<Compare)
	{
		Motor=1;
	}
	else
	{
		Motor=0;
	}
}